﻿# CMakeList.txt : CMake project for libcoro, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)

include ("${CMAKE_TOOLCHAIN_FILE}")

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("libcoro")

find_package(PThreads4W REQUIRED)

message(STATUS "PThreads4W_INCLUDE_DIR=${PThreads4W_INCLUDE_DIR}")

include_directories("$ENV{VLD_ROOT}\\include" ${PThreads4W_INCLUDE_DIR})
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
link_directories("$ENV{VLD_ROOT}\\lib\\Win32")
else()
link_directories("$ENV{VLD_ROOT}\\lib\\Win64")
endif()

add_library(libcoro STATIC coro.c)

# Add source to this project's executable.
add_executable (main1  "main1.c" "coro.c")

add_executable (main2  "main2.c" "coro.c")
target_compile_definitions(main2 PRIVATE CORO_ISOLATION)
target_compile_definitions(main2 PRIVATE MAX_CO_COUNT=16)
#target_link_directories(main2 PRIVATE "$ENV{VLD_ROOT}\\lib\\Win32")
target_link_libraries(main2 PRIVATE PThreads4W::PThreads4W)

add_executable (tp_main  "thread_pool_main.c" "thread_pool.c")
target_link_libraries(tp_main PRIVATE PThreads4W::PThreads4W)

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET main1 PROPERTY CXX_STANDARD 20)
  set_property(TARGET main2 PROPERTY CXX_STANDARD 20)
endif()

# TODO: Add tests and install targets if needed.
